﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using DTO;


namespace DAO
{
    public class LichChieuDAO
    {
        DataProvider dp = new DataProvider();
        public DataTable LayDanhSachLichChieu()
        {
            return dp.SqlExcuteQuery("sp_LayDanhSachLichChieu ");
        }
        public DataTable LayDanhSachCaChieu()
        {
            return dp.SqlExcuteQuery("sp_LayDanhSachMaCaChieu");
        }
        public DataTable LayDanhSachMaPhim()
        {
            return dp.SqlExcuteQuery("sp_LayDanhSachMaPhim");
        }
        public DataTable LayDanhSachMaTinhTrang()
        {
            return dp.SqlExcuteQuery("sp_LayDanhSachMaTinhTrang");
        }
        public DataTable DanhSachTimKiemTheoTenPhim(string tuKhoa)
        {
            SqlParameter param = new SqlParameter("@tuKhoa",tuKhoa);
            return dp.SqlExcuteQuery("sp_TimKiemTheoPhim", param);
        }

        public DataTable DanhSachTimKiemTheoCaChieu(string tuKhoa)
        {
            SqlParameter param = new SqlParameter("@tuKhoa", tuKhoa);
            return dp.SqlExcuteQuery("sp_TimKiemTheoCaChieu", param);
        }
        public void ThemLichChieu(LichChieuDTO lc)
        {
            SqlParameter[] param = {
                                     new SqlParameter("@MaPhim",lc.MaPhim ),
                                     new SqlParameter("@NgayBatDau",lc.NgayBatDau ),
                                     new SqlParameter("@NgayKetThuc",lc.NgayKetThuc ),
                                     new SqlParameter("@NgayChieu",lc.NgayChieu ),
                                     new SqlParameter("@MaCaChieu",lc.MaCaChieu ),
                                     new SqlParameter("@MaTinhTrang",lc.MaTinhTrang ),
                                                                         };
            dp.SqlExcuteNonQuery("sp_ThemLichChieu",param);
 
        }
        public void CapNhatLichChieu(LichChieuDTO lc)
        {
            SqlParameter[] param = {
                                     new SqlParameter("@MaPhim",lc.MaPhim ),
                                     new SqlParameter("@NgayBatDau",lc.NgayBatDau ),
                                     new SqlParameter("@NgayKetThuc",lc.NgayKetThuc ),
                                     new SqlParameter("@NgayChieu",lc.NgayChieu ),
                                     new SqlParameter("@MaCaChieu",lc.MaCaChieu ),
                                     new SqlParameter("@MaTinhTrang",lc.MaTinhTrang ),
                                                                         };
            dp.SqlExcuteNonQuery("sp_CapNhatLichChieu", param);

        }
        public DataTable LayMaPhimTheoTenPhim(string tenPhim)
        {
            SqlParameter param = new SqlParameter("@TenPhim",tenPhim);
            return dp.SqlExcuteQuery("sp_LayMaPhimTheoTenPhim", param);
        }
        public DataTable LayMaCaChieuTheoTenCaChieu(string tenCaChieu)
        {
            SqlParameter param = new SqlParameter("@TenCaChieu", tenCaChieu);
            return dp.SqlExcuteQuery("sp_LayMaCaChieuTheoTenCaChieu", param);
        }
        public void XoaLichChieu(string maPhim,string ngayChieu)
        {
            SqlParameter[] param = { 
                                       new SqlParameter("@MaPhim",maPhim),
                                       new SqlParameter("@NgayChieu",ngayChieu),
                                   };
             dp.SqlExcuteQuery("sp_XoaLichChieu", param); 
            
 
        }
    }
}
